import api from '@/api';

/**
 * 获取全部订单
 */
export const orderStatusGet = (data: any) => {
  let url = `/medinstrument/site/order/getOrderList?orderStatus=${data.status}`;
  if (data.status === 'afterSaleFlag') {
    url = '/medinstrument/site/order/getOrderList?backOrderFlag=YES';
  }
  return api.get(url, {
    limit: data.limit,
    page: data.page,
  });
};

/**
 * 获取订单详情
 */
export const orderDetailsGet = (data: any) => {
  return api.get(`/medinstrument/site/order/getOrderdetails?orderId=${data.orderId}`);
};

/**
 * 取消订单
 */
export const cancelOrderPost = (data: any) => {
  return api.post(`/medinstrument/site/order/cancelOrder?orderId=${data.orderId}&remark=''`);
};

/**
 * 再来一单
 */
export const addAgainPost = (data: any) => {
  return api.post(`/medinstrument/site/cart/addAgain?orderId=${data.orderId}`);
};

/**
 * 获取售后详情
 */
export const backDetailsGet = (data: any) => {
  return api.get(`/medinstrument/site/back/getBackDetails?orderId=${data.orderId}`);
};

/**
 * 上传接口
 */
export const uploadPost = (data: any) => {
  return api.post('/medinstrument/site/uploadSingleFile', data, 'file');
};

/**
 * 上传凭证和更新凭证
 */
export const paymentVoucherPost = (data: any) => {
  let url = `/medinstrument/site/order/uploadPaymentVoucher?orderId=${data.orderId}&payProof=${data.payProof}`;
  if (data.isChange) {
    url = `/medinstrument/site/order/updatePaymentVoucher?orderId=${data.orderId}&payProof=${data.payProof}`;
  }
  return api.post(url);
};

/**
 * 申请售后
 */
export const submitBackPost = (data: any) => {
  console.log('data', data);
  return api.post('/medinstrument/site/back/submitBack', data);
};

/**
 * 确认收货
 */
export const confirmReceiptPost = (data: any) => {
  return api.post(`/medinstrument/site/order/confirmReceipt?orderId=${data.orderId}`);
};

/**
 * 获取个人信息
 */
export const informationGet = () => {
  return api.get('/medinstrument/site/customer/information');
};

/**
 * 更新个人信息
 */
export const updateInformationPost = (data: any) => {
  return api.post('/medinstrument/site/customer/updateInformation', data);
};

/**
 * 新增证件
 */
export const addQualificationPost = (data: any) => {
  return api.post('/medinstrument/site/customer/addQualification', data);
};

/**
 * 更新证件
 */
export const updateQualificationPost = (data: any) => {
  return api.post('/medinstrument/site/customer/updateQualification', data);
};
//

/**
 * 验证码
 */
export const sendMessagePost = (data: any) => {
  return api.post('/medinstrument/site/sms/sendMessage', data);
};

/**
 * 更新账号
 */
export const updateLoginAccountPost = (data: any) => {
  return api.post(
    `/medinstrument/site/customer/updateLoginAccount?captcha=${data.captcha}&loginPhone=${data.loginPhone}`,
  );
};

/**
 * 修改密码
 */
export const changePasswordPost = (data: any) => {
  return api.post(
    `/medinstrument/site/customer/changePassword?newPassword=${data.newPassword}&oldPassword=${data.oldPassword}`,
  );
};
/**上传单号

 * 上传单号
 */
export const deliverPost = (data: any) => {
  return api.post(
    `/medinstrument/site/back/deliver?orderId=${data.orderId}&trackingNumber=${data.trackNumber}`,
  );
};

/**
 * 确认收款
 */
export const confirmPayPost = (data: any) => {
  return api.post(`/medinstrument/site/back/confirmPay?orderId=${data.orderId}`);
};

/**
 * 关闭售后
 */
export const closedAfterPost = (data: any) => {
  return api.post(`/medinstrument/site/back/closedAfterSale?orderId=${data.orderId}`);
};
